//
//  MenuLayer.m
//  Galaxy
//
//  Created by antl on 1/28/13.
//  Copyright (c) 2013 __MyCompanyName__. All rights reserved.
//

#import "MenuLayer.h"
#import "GameScene.h"
@implementation MenuLayer
-(id) init
{
	if(self==[super init])
	{
        [self initBackground];
    }
    return self;
}
-(void)dealloc
{
    [super dealloc];
}

#pragma mark - INIT-
-(void)initBackground
{
    /// ADD BACKGROUND GAME
    [self DrawImageSpritebyLayer:self andFileName:@"bg.png" atPosition:ccp(0,0) withZ:0 andScale:0 AnchorPoint:ccp(0,0)];
    
    /// ADD LABLE
    CCLabelTTF *lable=[CCLabelTTF labelWithString:@"GALAXIAN" fontName:@"Marker Felt" fontSize:50];
    [lable setAnchorPoint:ccp(0,0)];
    lable.position=ccp(50,380);
    [self addChild:lable];
    
    /// ADD MENU
    [CCMenuItemFont setFontSize:22];
    [CCMenuItemFont setFontName:@"Marker Felt"];
    /// item
    CCMenuItemFont* btPlay=[CCMenuItemFont itemWithString:@"Play"  target:self selector:@selector(clickButton:)];
    btPlay.tag=tagPlaying;
    CCMenuItemFont* btOptions=[CCMenuItemFont itemWithString:@"Options"  target:self selector:@selector(clickButton:)];
    btOptions.tag=tagbtOptions;
    CCMenuItemFont* btHelp=[CCMenuItemFont itemWithString:@"Help"  target:self selector:@selector(clickButton:)];
    btHelp.tag=tagbtHelp;
    CCMenuItemFont* btMoreGame=[CCMenuItemFont itemWithString:@"MoreGame"  target:self selector:@selector(clickButton:)];
    btMoreGame.tag=tagMoreGame;
    /// add item to menu
    CCMenu * iMenu=[CCMenu menuWithItems:btPlay,btOptions,btHelp,btMoreGame,nil];
    [iMenu alignItemsVertically];//alignItemsHorizontally
    [self addChild:iMenu];
    
}
-(void)clickButton:(id)sender
{
    CCMenuItemFont *item=(CCMenuItemFont*)sender;
    switch (item.tag) {
        case tagPlaying:
            //// playing 
            [self changePageWithScene:[GameScene node] type:FlipX];
            break;
        case tagbtOptions:
            //// Options 
            break;
        case tagbtHelp:
            //// Options 
            break;
        case tagMoreGame:
            //// Options 
            break;
        default:
            break;
    }
}

@end
